package com.kkd.kkdapp.wxapi;

import com.kkd.kkdapp.R;
import com.kkd.kkdapp.activity.MyRecommendFriendActivity;
import com.kkd.kkdapp.base.BaseActivity;
import com.kkd.kkdapp.utils.AppUtil;

import com.tencent.mm.sdk.openapi.BaseReq;
import com.tencent.mm.sdk.openapi.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.WXAPIFactory;

import android.os.Bundle;
import android.widget.Toast;

public class WXEntryActivity extends BaseActivity implements IWXAPIEventHandler {

	private IWXAPI api;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		api = WXAPIFactory.createWXAPI(this, "wx089678a5fca163a4", false);
		api.registerApp("wx089678a5fca163a4");
		api.handleIntent(getIntent(), this);
	}

	@Override
	public void onReq(BaseReq arg0) {

	}

	@Override
	public void onResp(BaseResp resp) {
		int result = 0;

		switch (resp.errCode) {
		case BaseResp.ErrCode.ERR_OK:
			result = R.string.errcode_success;
			// showToast("发送成功");
			BaseActivity.shareResult = 0;
			break;
		case BaseResp.ErrCode.ERR_USER_CANCEL:
			result = R.string.errcode_cancel;
			// showToast("发送失败");
			BaseActivity.shareResult = 1;
			break;
		case BaseResp.ErrCode.ERR_AUTH_DENIED:
			result = R.string.errcode_deny;
			// showToast("发送被拒绝");
			BaseActivity.shareResult = 1;
			break;
		default:
			result = R.string.errcode_unknown;
			// showToast("发送返回");
			BaseActivity.shareResult = 1;
			break;
		}
		// Toast.makeText(this, result, Toast.LENGTH_LONG).show();
		finish();
	}

	public void showToast(int hintLanguage) {
		AppUtil.makeToastForCustomer(this, hintLanguage);
	}

}
